package com.freedom.base.util;

import lombok.Data;

import java.util.Objects;

/**
 * @author freedom
 */
@Data
public class AjaxResult {

    private Object data;
    private String msg;
    private Boolean result;

    public static AjaxResult success () {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.result = true;
        ajaxResult.msg = "操作成功";
        return ajaxResult;
    }

    public static AjaxResult success ( Object data ) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.result = true;
        ajaxResult.msg = "操作成功";
        ajaxResult.data = data;
        return ajaxResult;
    }

    public static AjaxResult success ( Object data, String msg ) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.result = true;
        ajaxResult.msg = msg;
        ajaxResult.data = data;
        return ajaxResult;
    }

    public static AjaxResult success ( String msg ) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.result = true;
        ajaxResult.msg = msg;
        return ajaxResult;
    }


    public static AjaxResult error ( String msg ) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.result = true;
        ajaxResult.msg = msg;
        return ajaxResult;
    }


    public static AjaxResult error () {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.result = true;
        ajaxResult.msg = "操作失败";
        return ajaxResult;
    }

}
